﻿<UserControl x:Class="CodePlex.PropertyDesigner.PropertyDesignerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             xmlns:pd="clr-namespace:CodePlex.PropertyDesigner"
             Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d">

    <UserControl.Resources>

        <!-- BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.GridLineKey}}" -->
        
        <DataTemplate x:Key="PropertyAttributeNodeTemplate">
            <Grid SnapsToDevicePixels="True">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="Value"/>
                </Grid.ColumnDefinitions>
                <Border Grid.Column="0"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        Margin="0,-1,0,0"
                        SnapsToDevicePixels="True">
                    <TextBlock Text="{Binding Name}"
                               Margin="1"
                               SnapsToDevicePixels="True"/>
                </Border>
                <Border Grid.Column="1"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        Margin="-1,-1,0,0"
                        SnapsToDevicePixels="True">
                    <TextBlock Text="{Binding Value}"
                               Margin="1"
                               SnapsToDevicePixels="True"/>
                </Border>
            </Grid>
        </DataTemplate>
        
        <HierarchicalDataTemplate x:Key="PropertyNodeTemplate"
                                  ItemsSource="{Binding Nodes}"
                                  ItemTemplate="{StaticResource PropertyAttributeNodeTemplate}">
            <Grid SnapsToDevicePixels="True">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="Value"/>
                </Grid.ColumnDefinitions>
                <Border Grid.Column="0"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        Margin="0,-1,0,0"
                        SnapsToDevicePixels="True">
                    <TextBlock Text="{Binding Data.Name}"
                               Margin="1,1,1,2"
                               FontWeight="Bold"
                               SnapsToDevicePixels="True"/>
                </Border>
                <Border Grid.Column="1"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        Margin="-1,-1,0,0"
                        SnapsToDevicePixels="True">
                    <TextBlock Text="{Binding Data.TypeName}"
                               Margin="1,1,1,2"
                               SnapsToDevicePixels="True"/>
                </Border>
            </Grid>
        </HierarchicalDataTemplate>
        
    </UserControl.Resources>
    
    <Grid x:Name="DataContextRoot"
          DataContext="{x:Null}"
          d:DataContext="{d:DesignInstance Type={x:Type pd:PropertyDesignerControlModelSample}, IsDesignTimeCreatable=True}">
        <TreeView ItemsSource="{Binding Nodes}"
                  ItemTemplate="{StaticResource PropertyNodeTemplate}"
                  Grid.IsSharedSizeScope="True">
            <TreeView.ItemContainerStyle>
                <Style TargetType="TreeViewItem">
                    <Setter Property="IsExpanded" Value="True"/>
                </Style>
            </TreeView.ItemContainerStyle>
        </TreeView>
    </Grid>
    
</UserControl>
